<template>
	<view class="box">
		<view class="title">{{formData.title}}</view>
		<view class="titles">{{formData.source}}</view>
		<view
			style="display: flex;align-items: center;justify-content: space-between;font-size: 12px;padding: 10rpx 0;">
			<view style="color: #82848a;">{{formData.create_time}}</view>
			<view style="display: flex;align-items: center;color: #2979ff;"><uv-icon name="eye" color="#2979ff"
					size="14"></uv-icon>
				<view style="margin-left: 10rpx;">{{formData.read}}</view>
			</view>
		</view>
		<view class="content">
			<uv-parse :content="formData.content"></uv-parse>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				id: '',
				formData: {}
			}
		},
		onLoad(option) {
			this.id = option.id
			this.getDetail()
		},
		methods: {
			getDetail() {
				uni.showLoading({
					mask: true
				})
				uniCloud.callFunction({
					name: 'getDetail',
					data: {
						dbName: 'article',
						type: 'detail',
						id: this.id
					},
					success: res => {
						console.log('res', res)

						uniCloud.callFunction({
							name: 'getDetail',
							data: {
								dbName: 'article',
								type: 'read',
								id: this.id,
							},
							success: ress => {
								console.log('ress===>', ress)
								this.formData = ress.result.data
							}
						})
						uni.hideLoading()
					},
					fail: err => {
						uni.hideLoading()
						uni.showToast({
							title: '查询失败！',
							icon: 'none'
						})
					}
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.box {
		padding: 20rpx;

		.title {
			font-size: 32rpx;
			font-weight: bold;
			padding-bottom: 10rpx;
		}

		.content {
			margin: 20rpx 0;
		}
	}
</style>